package com.ruoyi.project.loan.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.project.loan.domain.RepaymentRecord;
import com.ruoyi.project.loan.mapper.RepaymentRecordMapper;
import com.ruoyi.project.loan.service.IRepaymentRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 还款记录Service业务层处理
 *
 * @author ruoyi
 * @date 2025-11-11
 */
@Service
public class RepaymentRecordServiceImpl implements IRepaymentRecordService {
    @Autowired
    private RepaymentRecordMapper repaymentRecordMapper;

    /**
     * 查询还款记录
     *
     * @param recordId 还款记录主键
     * @return 还款记录
     */
    @Override
    public RepaymentRecord selectRepaymentRecordByRecordId(Long recordId) {
        return repaymentRecordMapper.selectRepaymentRecordByRecordId(recordId);
    }

    /**
     * 查询还款记录列表
     *
     * @param repaymentRecord 还款记录
     * @return 还款记录
     */
    @Override
    public List<RepaymentRecord> selectRepaymentRecordList(RepaymentRecord repaymentRecord) {
        return repaymentRecordMapper.selectRepaymentRecordList(repaymentRecord);
    }

    /**
     * 新增还款记录
     *
     * @param repaymentRecord 还款记录
     * @return 结果
     */
    @Override
    public int insertRepaymentRecord(RepaymentRecord repaymentRecord) {
        repaymentRecord.setCreateTime(DateUtils.getNowDate());
        return repaymentRecordMapper.insertRepaymentRecord(repaymentRecord);
    }

    /**
     * 修改还款记录
     *
     * @param repaymentRecord 还款记录
     * @return 结果
     */
    @Override
    public int updateRepaymentRecord(RepaymentRecord repaymentRecord) {
        repaymentRecord.setUpdateTime(DateUtils.getNowDate());
        return repaymentRecordMapper.updateRepaymentRecord(repaymentRecord);
    }

    /**
     * 批量删除还款记录
     *
     * @param recordIds 需要删除的还款记录主键
     * @return 结果
     */
    @Override
    public int deleteRepaymentRecordByRecordIds(Long[] recordIds) {
        return repaymentRecordMapper.deleteRepaymentRecordByRecordIds(recordIds);
    }

    /**
     * 删除还款记录信息
     *
     * @param recordId 还款记录主键
     * @return 结果
     */
    @Override
    public int deleteRepaymentRecordByRecordId(Long recordId) {
        return repaymentRecordMapper.deleteRepaymentRecordByRecordId(recordId);
    }
}
